package com.wkq.util


/**
 *
 *@Author: wkq
 *
 *@Time: 2025/8/8 14:12
 *
 *@Desc:
 */
object SoUtil {
    init {
        System.loadLibrary("SoUtil")
    }

    private external fun getDecryptedIV(): String
    private external fun getDecryptedKey(): String
    private external fun readSelfMaps(): String
    private external fun getDecryptedSha256(): String
    private external fun getDecryptedPublicKey(): String
    private external fun getDecryptedCN(): String
    private external fun checkTimerBombAndCrash()

    // 要和c代码中的 key对应上才能解密
    val xorKey = byteArrayOf(0x55, 0x23, 0x66, 0x13)


    fun getKeyArray(): ByteArray {
        return XOREncryptor.encrypt("g1efc4i96x5bnu87", xorKey)
    }

    fun getIVArray(): ByteArray {
        return XOREncryptor.encrypt("it520r3vouaw6eq9", xorKey)
    }

    /**
     * 获取解密的256
     * @return String?
     */
    fun getCDecryptedCN(): String? {
        return getDecryptedCN()
    }
    /**
     * 获取解密的256
     * @return String?
     */
    fun getCDecryptedSha256(): String? {
        return getDecryptedSha256()
    }

    /**
     * 获取解密的Ikey
     * @return String?
     */
    fun getCDecryptedPublicKey(): String? {
        return getDecryptedPublicKey()
    }

    /**
     * 获取解密的IV
     * @return String?
     */
    fun getCDecryptedIV(): String? {
        return getDecryptedIV()
    }

    /**
     * 获取解密后的KEY
     * @return String?
     */
    fun getCDecryptedKey(): String? {
        return getDecryptedKey()
    }

    /**
     * 虚拟空间获取self/maps的加载文件内容
     * @return String?
     */
    fun getReadProcSelfMaps(): String? {
        return readSelfMaps()
    }
    /**
    * 超时检测
     */
    fun checkTimeLimit(){
        checkTimerBombAndCrash()
    }
}